#NETWORK setting:
FLOATING_IP_START=195.19.226.136
FLOATING_IP_END=195.19.226.139
EXTERNAL_NETWORK_GATEWAY=195.19.226.129
EXTERNAL_NETWORK_CIDR=195.19.226.129/27
PRIVATE_NETWORK_GATEWAY=10.0.0.1
PRIVATE_NETWORK_CIDR=10.0.0.0/24
CEPH_NETWORK_GATEWAY=10.30.30.1
CEPH_NETWORK_CIDR=10.30.30.0/24
CEPH_IP_START=10.30.30.2
CEPH_IP_END=10.30.30.128

neutron net-create ext-net --shared --router:external=True
neutron subnet-create ext-net --name ext-subnet --allocation-pool start=$FLOATING_IP_START,end=$FLOATING_IP_END  --disable-dhcp --gateway $EXTERNAL_NETWORK_GATEWAY $EXTERNAL_NETWORK_CIDR

neutron net-create private-net 
neutron subnet-create private-net --name private-subnet --gateway $PRIVATE_NETWORK_GATEWAY $PRIVATE_NETWORK_CIDR

neutron router-create main-router
neutron router-interface-add main-router private-subnet
neutron router-gateway-set main-router ext-net

neutron net-create ceph-net
neutron subnet-create ceph-net --name ceph-subnet --allocation-pool start=$CEPH_IP_START,end=$CEPH_IP_END $CEPH_NETWORK_CIDR





#Image create
glance image-create --name=centossimple0 --disk-format=qcow2 --container-format=bare  --is-public=true < /net/alice22/se2/disks/simplecentos0.qcow2

#Create boot volume
IMAGE_ID=`glance image-list | grep centossimple0| awk '{print $2}'`
nova volume-create --image-id $IMAGE_ID --display-name centosboot0 20


#Create machine 
VOL_ID=`cinder list| grep centosboot0| awk '{print $2}'`
PRIVATE_NET_ID=`neutron net-list |grep private-net| awk '{print $2}'`
CEPH_NET_ID=`neutron net-list |grep ceph-net| awk '{print $2}'`
nova boot --flavor m1.small --boot-volume=$VOL_ID --nic net-id=$PRIVATE_NET_ID --nic net-id=$CEPH_NET_ID --security-group default centos001

#Floating
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
IP=`neutron floatingip-create ext-net |grep floating_ip_address| awk '{print $4}'`
neutron floatingip-list
nova floating-ip-associate   centos001 $IP
